package com.guowei.jiecloudbackstage.roommessage.mapper;

import com.guowei.jiecloudbackstage.roommessage.entity.Roommessage;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author ym
 * @since 2021-07-13
 */
public interface RoommessageMapper extends BaseMapper<Roommessage> {

    /**
     * 查询全部房间信息
     *
     * @return
     */
    @Select("SELECT rm.roomId,r.roomType,rm.roomState,rm.roomEnvironment,rm.roomPhone FROM `roommessage` rm,room r where rm.roomType = #{roomId}")
    List<Roommessage> selectAll();

    /**
     * 查询可用房间数
     *
     * @return
     */
    @Select("select COUNT(roomState) from roommessage WHERE roomState = '空房间'")
    int roomAbleCount();

    /**
     * 查询已住房间数
     *
     * @return
     */
    @Select("select COUNT(roomState) from roommessage WHERE roomState = '已入住' or roomState = '未入住'")
    int roomUnAbleCount();

    /**
     * 查询全部房间数
     *
     * @return
     */
    @Select("SELECT COUNT(*) from roommessage")
    int roomCount();

    /**
     * 查询干净房间数
     *
     * @return
     */
    @Select("SELECT count(*) from roommessage where roomEnvironment = '干净'")
    int roomClear();

    /**
     * 查询脏房房间数
     *
     * @return
     */
    @Select("SELECT count(*) from roommessage where roomEnvironment = '脏房'")
    int roomDirty();

}
